import { getFoot } from '../api/foot.js';
Component({
  data: {
    selected: 0,
    color: "#7A7E83",
    selectedColor: "#3cc51f",
    list: [
      {
        "pagePath": "/pages/index/index",
        "iconPath": "../images/1-001.png",
        "selectedIconPath": "../images/1-002.png",
        "text": "首页"
      },
      {
        "pagePath": "/pages/goods_cate/goods_cate",
        "iconPath": "../images/2-001.png",
        "selectedIconPath": "../images/2-002.png",
        "text": "分类"
      },
      {
        "pagePath": "/pages/order_addcart/order_addcart",
        "iconPath": "../images/3-001.png",
        "selectedIconPath": "../images/3-002.png",
        "text": "购物车"
      },
      {
        "pagePath": "/pages/user/user",
        "iconPath": "../images/4-001.png",
        "selectedIconPath": "../images/4-002.png",
        "text": "我的"
      }
    ]
  },
  attached() {
    this.getFoot()
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      wx.setStorageSync('selectedIndex',data.index);
      wx.switchTab({url})
      this.setData({
        selected: data.index
      })
    },
    getFoot(){
      var that = this
      getFoot().then(res=>{
        var  menus = res.data.menus;
        if(menus.length > 0){
          that.setData({ list: res.data.menus });
        }   
      })
    }
  }
})